<!DOCTYPE html>

<html>

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>居中的元素</title>

    <style type="text/css">
        body {
            margin: 0;
            padding: 0;
        }
        
        .wrapper {
            /* 50% of viewport's width. */
            width: 50vw;
            /* 50% of viewport's height. */
            height: 50vh;
            background: #6666fa;
            margin: 25vh 25vw;
        }
    </style>

</head>

<body>

    <div class="wrapper"></div>

</body>

</html>